package com.example.presentshopping.ui.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.example.presentshopping.R
import com.example.presentshopping.config.base.BaseMvpActivity
import com.example.presentshopping.config.bean.YDClassifyItemBean
import com.example.presentshopping.net.http.HttpRequest
import com.example.presentshopping.ui.fragment.ProductListFragment
import com.example.presentshopping.ui.fragment.earnings.RefundetailFragment
import com.example.presentshopping.utils.tool.GsonUtils
import kotlinx.android.synthetic.main.activity_refundetail.*

//分类商品
class ProductListActivity : BaseMvpActivity() {


    var datastring: String? = null
    var name: String? = null
    var categoryid: String? = null
    var ydClassifyItemBean: YDClassifyItemBean? = null
    var ifyItemBean :  YDClassifyItemBean.DataBean.ListBean ?=null
    var position :  String  ?=null

    val pageViews = ArrayList<Fragment>()
    override val layoutId: Int
        get() = R.layout.activity_refundetail

    override fun initView(savedInstanceState: Bundle?) {

        datastring = intent.getStringExtra("data")
        name = intent.getStringExtra("categoryListBean")
        categoryid = intent.getStringExtra("categoryid")
        position = intent.getStringExtra("position")

        ydClassifyItemBean =
            GsonUtils.getGson().fromJson(datastring, YDClassifyItemBean().javaClass)

        ydClassifyItemBean
        title_main_tv.leftBackImageTv.setOnClickListener { finish() }
        title_main_tv.titleTv.text = name

        for (ifyItemBean in ydClassifyItemBean?.data?.list!!){
            pageViews.add(ProductListFragment(this, ifyItemBean))
        }

        tablayout.setViewPager(SpecialViewPager,
            HttpRequest.getTeli(ydClassifyItemBean?.data?.list).toTypedArray(),this,pageViews)

        tablayout.currentTab  = position?.toInt()!!

    }



    override fun showToast(msg: String?) {

    }

    override fun onSuccess(data: String?) {

    }

    override fun onFailure(e: Throwable?, code: Int, msg: String?, isNetWorkError: Boolean) {

    }
}